package com.dyh.quickdemozwei;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@Configuration
public class ListBeanConfig {

    @Setter@Getter@AllArgsConstructor@NoArgsConstructor
    class X {
        String name;
    }


    class Y{
        X x;
        String back;
        String getName(){
            return x.getName()+back;
        }
    }

    @Bean
    X x1(){
        return new X("x1");
    }

    @Bean
    X x2(){
        return new X("x2");
    }


    @Bean
    Map<String,X> xMap(List<X> xList){
        return xList.stream().collect(Collectors.toMap(e->e.getName(), Function.identity()));
    }
}
